package interview;

public class interview_10_01 {
    public void merge(int[] A, int m, int[] B, int n) {
        for(int i=m-1;i>=0;--i){
            A[i+n]=A[i];
        }
        int left=n;
        int right=0;
        int index=0;
        while(left<m+n&&right<n){
            if(A[left]<B[right]){
                A[index]=A[left];
                left++;
            }
            else{
                A[index]=B[right];
                right++;
            }
            index++;
        }
        while(left<m+n){
            A[index]=A[left];
            left++;
            index++;
        }
        while(right<n){
            A[index]=B[right];
            right++;
            index++;
        }
    }
}
